<?php

use yii\db\Schema;
use yii\db\Migration;

class m160719_084613_add_adspace_cpe_fields extends Migration
{
    public function up()
    {
        $sql = <<<FINE
alter table {{%adspace}} add column cpe_support int(1) not null default 0 comment 'can be used for cpe, 0 not support, 1 support' after page_url;
alter table {{%adspace}} add column cpe_format_list varchar(32) default null comment 'supported material format, 5 flv, 6 mp4, 7 ogg, 8 webm' after cpe_support;
alter table {{%adspace}} add column cpe_mode int(10) default null comment 'cpe video play mode, 1 auto play, 2 play on mouse over' after cpe_format_list;
alter table {{%adspace}} add column cpe_width int(10) unsigned not null comment '宽' after cpe_mode;
alter table {{%adspace}} add column cpe_height int(10) unsigned not null comment '高' after cpe_width;
alter table {{%adspace}} add column cpe_duration int(10) default null comment 'video duration' after cpe_height;
alter table {{%adspace}} add column cpe_base_price decimal(10,2) default null comment 'CPE底价' after cpe_duration;
FINE;
        return $this->execute($sql);
    }

    public function down()
    {
        $this->dropColumn('{{%adspace}}', 'cpe_support');
        $this->dropColumn('{{%adspace}}', 'cpe_format_list');
        $this->dropColumn('{{%adspace}}', 'cpe_mode');
        $this->dropColumn('{{%adspace}}', 'cpe_width');
        $this->dropColumn('{{%adspace}}', 'cpe_height');
        $this->dropColumn('{{%adspace}}', 'cpe_duration');
        return $this->dropColumn('{{%adspace}}', 'cpe_base_price');
    }

    /*
    // Use safeUp/safeDown to run migration code within a transaction
    public function safeUp()
    {
    }

    public function safeDown()
    {
    }
    */
}
